﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using G15_Agent.Models.Airplane;

namespace G15_Agent.Models.ViewModels.AirplaneViewModels
{
    public class AirplaneSearchViewModel
    {
        public string serviceID { set; get; }
        public List<SelectListItem> dsDiemDi { set; get; }
        public List<SelectListItem> dsDiemDen { set; get; }
        public List<SelectListItem> dsLoaiVe { set; get; }
        public IEnumerable<SelectListItem> optionSoLuong
        {
            get
            {
                int[] dsSL = new int[] { 0, 1, 2, 3, 4, 5 };
                return new SelectList(dsSL);
       
            }
        }

        public string typeTrip { set; get; }

        [DisplayName("Loại vé")]
        public string type { set; get; }
    
        [DisplayName("Đi từ")]
        public string maDiemDi { set; get; }
        [DisplayName("Đi đến")]
        public string maDiemDen { set; get; }

        [DisplayName("Ngày đi")]
        [DataType(DataType.Date)]
        public DateTime tgDi { set; get; }
        [DisplayName("Ngày về")]
        [DataType(DataType.Date)]
        public DateTime tgDen { set; get; }

        [DisplayName("Số người lớn")]
        [Range(0, int.MaxValue)]
        [DataType("Number")]
        public int slLon { set; get; }
        [DisplayName("Số trẻ em")]
        [DataType("Number")]
        [Range(0, int.MaxValue)]
        public int slNho { set; get; }

        public AirplaneSearchViewModel()
        {
            dsDiemDi = new List<SelectListItem>();
            dsDiemDen = new List<SelectListItem>();
            dsLoaiVe = new List<SelectListItem>();
        }

        public List<SelectListItem> GetAirportSelectList(List<SanBay> listSanBay)
        {
            List<SelectListItem> result = new List<SelectListItem>();

            foreach (var sanbay in listSanBay)
            {
                result.Add(new SelectListItem
                {
                    Value = sanbay.maSanBay,
                    Text = sanbay.tenQuocGia + "_" + sanbay.tenKhuVuc + "_" + sanbay.tenSanBay
                });
            }

            return result;
        }

        public List<SelectListItem> GetTicketSelectList(List<LoaiVe> listVeMayBay)
        {
            List<SelectListItem> result = new List<SelectListItem>();

            foreach (var ve in listVeMayBay)
            {
                result.Add(new SelectListItem
                {
                    Value = ve.maLoaiVe,
                    Text = ve.tenLoaiVe
                });
            }

            return result;
        }
    }
}